/*
 *  $Id: ManaRogue.cs 1051 2010-05-18 22:10:41Z thenn.erannor $
 *	This file is a part of Ragima CCG.
 *	(C) 2008 Ragima development group.
 *
 *	Licensed under the terms of the GNU GPL License version 2.
 *
 */

namespace Ragima.Cards001.Air.Creatures {
    public class ManaRogue: CreatureCard {
        public ManaRogue(): base("001_a_c_mana_rogue") {
            Level = CompleteLevel.ReadyForTest;
            Element = ElementType.Air;
            Value = 100;
            Damage = 2;
            Health = 2;
            AddManaCost(ElementType.Air, 2);
        }

        public override void SetNaturalAffects(ICollector<Affect> affects) {
            affects.Add(new Affects.OnHit(DoHit, AffectSummaryType.Local));
        }

        private static ElementType[] LockedElements = {ElementType.Neutral, ElementType.Light, ElementType.Darkness, ElementType.Fire, ElementType.Water, ElementType.Earth,ElementType.Air};

        private static readonly Languages.CardPhrase<ManaRogue> Action = new Languages.CardPhrase<ManaRogue>("action");

        private static void DoHit(Creature hitter, AbstractObject target, int damage) {
            if (target is Player) {
                int dice = Game.Current.GetDiceNextValue();
                ElementType element = LockedElements[dice];
                Game.Current.Log.Add(Action.Phrase, hitter, element);
                target.AddAffect(new ManaRogueAffect(element));
            }
        }

        private class ManaRogueAffect: SpellAffect<ManaRogue> {
            public ElementType LockedElement;

            public ManaRogueAffect(ElementType element): base(true) {
                DefaultDescription = true;
                LockedElement = element;
                Add(new TimeAffect(2, new Affects.ManaLock(element, true, false)));
            }

            public override string DescriptionText {
                get { return Description.GetText(LockedElement); }
            }

            public override bool Dispellable {
                get { return false; }
            }

            public override Affect Clone() {
                return new ManaRogueAffect(LockedElement);
            }
        }
    }
}
